package io.renren.modules.backstage.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.backstage.entity.PaylogEntity;
import io.renren.modules.backstage.service.PaylogService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 支付日志表
 *
 * @author ian
 * @email ian.ren121@gmail.com
 * @date 2022-04-21 19:34:31
 */
@RestController
@RequestMapping("backstage/paylog")
public class PaylogController {
    @Autowired
    private PaylogService paylogService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("backstage:paylog:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = paylogService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{outTradeNo}")
    @RequiresPermissions("backstage:paylog:info")
    public R info(@PathVariable("outTradeNo") String outTradeNo){
		PaylogEntity paylog = paylogService.getById(outTradeNo);

        return R.ok().put("paylog", paylog);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("backstage:paylog:save")
    public R save(@RequestBody PaylogEntity paylog){
		paylogService.save(paylog);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("backstage:paylog:update")
    public R update(@RequestBody PaylogEntity paylog){
		paylogService.updateById(paylog);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("backstage:paylog:delete")
    public R delete(@RequestBody String[] outTradeNos){
		paylogService.removeByIds(Arrays.asList(outTradeNos));

        return R.ok();
    }

}
